/**
 * 
 */
package org.wolf.common.config;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

/**
 * @author 何小锋
 * 
 */
@XmlType
@XmlAccessorType(XmlAccessType.NONE)
public class ClusterServerCfg implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * IP Adress
	 */
	@XmlAttribute
	private String ip;
	/**
	 * 和Leader通讯的端口
	 */
	@XmlAttribute
	private Integer port = 2888;
	/**
	 * 重新选举Leader的端口
	 */
	@XmlAttribute
	private Integer electionPort = 3888;
	/**
	 * 类型
	 */
	@XmlAttribute
	private String type = "PARTICIPANT";
	/**
	 * 权重
	 */
	@XmlAttribute
	private Long weight;
	/**
	 * 分组
	 */
	@XmlAttribute
	private Long group = 1L;

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Integer getPort() {
		if (port == null || port <= 0)
			port = 2888;
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public Integer getElectionPort() {
		if (electionPort == null || electionPort <= 0)
			electionPort = 3888;
		return electionPort;
	}

	public void setElectionPort(Integer electionPort) {
		this.electionPort = electionPort;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getWeight() {
		if (weight == null)
			weight = 1L;
		return weight;
	}

	public void setWeight(Long weight) {
		this.weight = weight;
	}

	public Long getGroup() {
		return group;
	}

	public void setGroup(Long group) {
		this.group = group;
	}

}
